//
//  TDTitleBtn.m
//  EBOexchange
//
//  Created by WWJ on 2017/12/29.
//  Copyright © 2017年 ebo. All rights reserved.
//

#import "TDTitleBtn.h"

@implementation TDTitleBtn
- (instancetype)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
//            [self setTitleColor:kNaviTitleCorlor forState:UIControlStateNormal];
            self.titleLabel.adjustsFontSizeToFitWidth = YES;
            self.titleLabel.textAlignment = NSTextAlignmentCenter;
            self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        }
        return self;
    }
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        self.titleLabel.adjustsFontSizeToFitWidth = YES;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;

    }
    return self;
}
- (CGRect)titleRectForContentRect:(CGRect)contentRect
    {
        CGFloat titleX = 0;
        CGFloat titleY = 0;
        CGFloat titleW = self.yzWidth-23;
        CGFloat titleH = self.yzHeight;

        return CGRectMake(titleX, titleY, titleW, titleH);
    }

- (CGRect)imageRectForContentRect:(CGRect)contentRect
    {
        CGFloat imageH = 10;
        CGFloat imageW = 10;
        CGFloat imageY = (self.yzHeight - imageH) * 0.5;
        CGFloat imageX = CGRectGetMaxX(self.titleLabel.frame)+5;
        return CGRectMake(imageX, imageY, imageW, imageH);
    }
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
